package com.shiwenping.reply.recycle;

import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

/**
 *
 * @author haichecker
 * @date 17-11-8
 */

public class MyGestureListener extends GestureDetector.SimpleOnGestureListener{
    private OnItemClickListener onItemClickListener;
    private RecyclerView mRecyclerView;

    public MyGestureListener(OnItemClickListener onItemClickListener, RecyclerView mRecyclerView) {
        this.onItemClickListener = onItemClickListener;
        this.mRecyclerView = mRecyclerView;
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        View childe = mRecyclerView.findChildViewUnder(e.getX(), e.getY());
        if (childe != null) {
            RecyclerView.ViewHolder viewHolder = mRecyclerView.getChildViewHolder(childe);
            onItemClickListener.onClick(viewHolder,viewHolder.getLayoutPosition());
        }
        return true;
    }

    @Override
    public void onLongPress(MotionEvent e) {
        super.onLongPress(e);
    }
}
